<?php
session_start();

include("./class/template.inc");

/*验证Session*/
if( isset($_SESSION['user']) ){
	header("Location:/index.php");
	exit();
}
$error = "";
/*接收登录请求*/
if( isset($_POST["user"]) && isset($_POST["pwd"]) ){
	if( AdPlatformLogin($_POST['user'], $_POST['pwd']) ){
		header("Location:/index.php"); // 登录成功
		exit();
	}
	$error = "用户密或密码错误";
}
/*调用模板*/
$tpl = new Template("./ui/");
$tpl->set_file("main", "login.html");
$tpl->set_var("Error", $error);
$tpl->parse("mains", "main");
$tpl->p("mains");
exit();
/*函数定义*/
function AdPlatformLogin($user, $pwd){
	if("" == $user)
		return false;
	/*if($user != $pwd)
		return false;*/
	if($user != "root" || md5("http://www.help100.cn/email/{$pwd}") != "e5fa51a254d19d15e4a01ff9a5964f66")
		return false;
	$_SESSION["user"] = $user;
	return true;
}
?>

